/**
 * @file bull_hal_sys_queue.h
 * @brief 
 * @author yejing (yejh@gongniu.cn)
 * @version 1.0
 * @date 2024-05-09
 * 
 * Copyright 2021-2023 GongNiu Inc. All Rights Reserved.
 * 
 */

#ifndef __BULL_HAL_SYS_QUEUE_H__
#define __BULL_HAL_SYS_QUEUE_H__

#include "bull_hal_adapter.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief create queue
 *
 * @param[out]     queue      queue to be create
 * @param[in]      size       the deep of the queue
 * @return  OPRT_OS_ADAPTER_OK: SUCCESS other:fail
 */
int bull_hal_sys_queue_create(QUEUE_HANDLE *queue, int message_size, int number_of_messages);

/**
 * @brief free queue
 *
 * @param[in]     queue      queue to be free
 * @return  void
 */
void bull_hal_sys_queue_delete(QUEUE_HANDLE queue);

/**
 * @brief fetch msg from queue in timeout ms, copy data to queue
 *
 * @param[in]      queue      queue to post
 * @param[in]      msg        msg to post
 * @param[in]      timeout    max time to wait for msg(ms), BULL_HAL_SYS_QUEUE_FOREVER means forever wait
 * @return  int OPRT_OS_ADAPTER_OK:success    other:fail
 */
int bull_hal_sys_queue_post(QUEUE_HANDLE queue, void *msg, unsigned int timeout);

/**
 * @brief fetch msg from queue in timeout ms, copy data from queue
 *
 * @param[in]      queue      queue to post
 * @param[out]     msg        msg to fetch
 * @param[in]      timeout    max time to wait for msg(ms), BULL_HAL_SYS_QUEUE_FOREVER means forever wait
 * @return  int OPRT_OS_ADAPTER_OK:success    other:fail
 */
int bull_hal_sys_queue_fetch(QUEUE_HANDLE queue, void *msg, unsigned int timeout);


#ifdef __cplusplus
}
#endif

#endif